#include <iostream>
#include <cmath>

using namespace std;

double calcWACC(double Rd,double D,double t,double Re,double V)
{
	double WACC = 0;

	WACC = ((V-D)/V)*Re + (D/V)*Rd * (1-t)  ;  

	return WACC;

}

void WACCCalc()
{	
	double Rd;
	double D;
	double t;
	double Re;
    double V;
	double WACC;

	cout << "Welcome to Weighted Average Cost of Capital Calculator" << endl;
	cout << "Programmed By Tuan Bui" << endl;

	cout << endl;

	cout << "What is the cost of debt? ";
	cin >> Rd;

	cout << "What is the market value of debt? ";
	cin >> D;

	cout << "What is the tax rate? ";
	cin >> t;
    
    cout << "What is the cost of equity? ";
	cin >> Re;

	cout << "What is Total value of all capital (Debt + Equity)? ";
	cin >> V;

	WACC = calcWACC(Rd,D,t,Re,V);

	cout << "The Weighted Average Cost of Capital: " << WACC << endl;

	system("PAUSE");
}
